#include <iostream>
using namespace std;

class Test
{
public:
    int removeElement(int *nums, int numsSize, int val)
    {
        int src = 0;
        int dst = 0;
        //思想：双指针 -> 当nums[src]不等于val时则将nums[src]的值覆盖到nums[dst]上并且src和dst自增
        //->当等于时则src自增，因为等于的数不用覆盖
        //时间复杂度：O(N) 空间复杂度：O(1)
        while (src < numsSize)
        {
            if (nums[src] != val)
            {
                nums[dst] = nums[src];
                src++;
                dst++;
            }
            else
            {
                src++;
            }
        }
        return dst;
    }
};

int main()
{
    int nums[10];
    for (int i = 0; i < 10; ++i)
    {
        cin >> nums[i];
    }
    int val;
    cin >> val;

    Test t;
    int Size = t.removeElement(nums, sizeof(nums) / sizeof(nums[0]), val);
    for (int i = 0; i < Size; ++i)
    {
        cout << nums[i] << ' ';
    }
    cout << '\n';
    system("pause");
    return 0;
}